<template>
    <div class="changeaccount">
        <el-dialog
            title="提示"
            :visible.sync="dialogVisible"
            width="30%"
            :before-close="handleClose">
            <span>您确定注销{{userInfo.name}}用户吗?</span>
            <span slot="footer" class="dialog-footer">
            <el-button @click="quxiao">取 消</el-button>
            <el-button type="primary" @click="close">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
export default {
  data() {
    return {
      dialogVisible: false,
      userInfo: ""
    };
  },
  methods: {
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    quxiao(){
      this.dialogVisible = false;
      this.$router.go(-1);
    },
    close() {
      this.dialogVisible = false;
      localStorage.removeItem('userInfo');
      this.$message('注销成功,请重新登录!');
      this.$router.push({path:'/'});
    }
  },
  created() {
    this.userInfo = JSON.parse(localStorage.userInfo);
    this.dialogVisible = true;
  }
};
</script>
<style scoped>
.changeaccount {
  width: 100%;
}
</style>
